<?php
namespace Admin\Controller;
use Think\Controller;
header("Content-Type:text/html; charset=utf-8");
class ActicleController extends CommonController {
      public function indexAction(){
        $this->display();
    }
    //用户文章列表
    public function acticle_listAction(){
        $acticle=D('Acticle');
        $res=$acticle->acticle_list();
        //$string=implode($res['list']);
       /* $a= $res['list'];
        foreach ($a as $key => $value) {
            $uid=$value['uid'];
        } //print_r($res);exit('123');*/
        $this->assign('uid',$res['uid']);// 赋值数据集
        $this->assign('list',$res['list']);// 赋值数据集
        $this->assign('page',$res['page']);// 赋值分页输出
        $this->display('index'); // 输出模板
    }

    public function addAction(){
        $add_acticle=D('Acticle');
        $res=$add_acticle->add();

        $this->assign('list',$res);
        $this->display('add');
       
    }
    
    //添加用户文章
    public function add_acticleAction(){
        $add_acticle=D('Acticle');
        $res=$add_acticle->add_acticle();
        $uid=$res['uid'];
        if ($res) {
           $this->success('添加成功',U('Acticle/acticle_list?uid='.$uid.''));
        }
       
    }
    //上传文件
   /* public function uploadAction(){
        $upload=D('Acticle');
        $res=$upload->upload();
        if ($res=='1') {
            $this->error($upload->getError());
        }else{
            $this->success('上传成功！');
        }
    }*/
    public function updateAction(){
        $update=D('Acticle');
        $res=$update->update();
        //print_r($res);exit('123');
        $this->assign('list',$res);
        $this->display('update');
    }
    //文章修改
    public function update_acticleAction(){
        $update=D('Acticle');
        $res=$update->update_acticle();
	
        if($res['res']) {
           $this->success('修改成功',U('Acticle/acticle_list?uid='.$res['uid'].''));
        }else{
            $this->error('修改失败');
        }
    }
    //文章删除
    public function del_acticleAction(){
        $del=D('Acticle');
        $res=$del->del_acticle();
        if ($res==1) {
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
    }
    public function update_typeAction(){
        $type=I('type');
        $id=I('id');
        $acticle=M('acticle');
        $data=array(
            'type'=>$type,
            );
        $re=$acticle->where('id='.$id)->save($data);
       
    }
    
    
}